﻿using System;
using System.Xml.Serialization;
using EpiNEXT.Services.Fields;

namespace EpiNEXT.Services.Validation.Actions
{
    //[Serializable()]
    public sealed class Action_Clear : ActionBase
    {
        public override void Execute(Record record)
        {
            DataEntryInstrument form = record.Form;

            foreach (string fieldName in this.TargetNames)
            {
                IField field = record.Form.Fields[fieldName];
                switch(field.DataType) 
                {
                    case "System.String":
                        record.AddOrUpdateFieldData(field, String.Empty);
                        break;
                    default:
                        record.AddOrUpdateFieldData(field, null);
                        break;
                }
                
            }
        }
    }
}
